﻿using System;
using System.Collections.Generic;
using System.Text;
using Castle.DynamicProxy;
using System.Linq;

namespace PlutoStudio.Aspects
{
    internal class ConventionaInterceptorContext : IConventionaInterceptorContext
    {
        private readonly IDictionary<Type, TypeInterceptorMap> _maps;
        public ConventionaInterceptorContext(IDictionary<Type,TypeInterceptorMap> maps)
        {
            _maps =maps;
        }
        public void Add(Type type, Type interceptor)
        {
            var map = _maps.GetOrAdd(type, t => new TypeInterceptorMap(t));
            map.AddInterceptor(interceptor);
        }
    }
}
